package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.UserDao;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ly
 * @Date: 2021/07/14/18:41
 * @Description:
 */
@Service
public class UserServiceImpl  implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User findById(Integer id) {
        return  userDao.findById(id);
    }


    @Override
    public PageInfo<User> findAll(int page,int size) {
        PageHelper.startPage(page,size);
        List<User> all = userDao.findAll();
        return  new PageInfo<User>(all);
    }


    @Override
    public Integer addUser(User user) {
        return userDao.addUser(user);
    }


    @Override
    public Integer deleteUser(Integer id) {
        return userDao.deleteUser(id);
    }


    @Override
    public Integer updateUser(User user) {
        return userDao.updateUser(user);
    }
}
